<?php

declare(strict_types=1);

namespace App\Marketing\Model;

use App\Fastapp\Model\Account;
use Hyperf\Database\Model\Relations\HasOne;
use Mine\MineModel;

/**
 * @property int $id 主键
 * @property \Carbon\Carbon $created_at 
 * @property \Carbon\Carbon $updated_at 
 * @property int $user_id 用户id
 * @property int $lotto_id 彩票id
 * @property string $no 号码
 * @property int $num 注数
 * @property int $periods 期数
 * @property int $level 中奖等级
 * @property string $amount 中奖金额
 * @property int $status 领取0否1是
 * @property-read null|Account $user 
 */
class MarketingLottoLog extends MineModel
{
    /**
     * The table associated with the model.
     */
    protected ?string $table = 'marketing_lotto_log';

    /**
     * The attributes that are mass assignable.
     */
    protected array $fillable = ['id', 'created_at', 'updated_at', 'user_id', 'lotto_id', 'no', 'num', 'periods', 'level', 'amount', 'status'];

    /**
     * The attributes that should be cast to native types.
     */
    protected array $casts = ['id' => 'integer', 'created_at' => 'datetime', 'updated_at' => 'datetime', 'user_id' => 'integer', 'lotto_id' => 'integer', 'num' => 'integer', 'periods' => 'integer', 'level' => 'integer', 'amount' => 'decimal:2', 'status' => 'integer'];

    public function user(): HasOne
    {
        return $this->hasOne(Account::class, 'gene_id', 'user_id');
    }
}
